<template>
  <div class="con">
    <div class="contbox6_10">
      <p class="titlelist6_10 titlser">
        库存明细
        <span style="color: #999">&nbsp;&nbsp;/&nbsp;&nbsp;</span>转让
      </p>
      <div class="content">
        <el-form :model="shelves" class="demo-form-inline">
          <el-row style="display:flex;aligin-item:center">
            <el-form-item label="转让对象：" label-width="110px" class="status">
              <el-cascader
                filterable
                ref="cascaderAddr"
                v-model="fficeUids"
                :options="options"
                :props="{ checkStrictly: true, emitPath: false }"
                clearable
              ></el-cascader>
            </el-form-item>
            <div class="button" style="margin-top:3px">
              <el-button @click="sure" type="primary">确认</el-button>
              <el-button @click="cancle">取消</el-button>
            </div>
          </el-row>
        </el-form>
        <el-table
          :data="tableData"
          :header-cell-style="{ background: '#F9FAFC', color: '#222' }"
          stripe
          border
          :row-style="{ height: '0px' }"
          :cell-style="{ padding: '0px' }"
          v-loading="listLoading"
          :fit="true"
        >
          <el-table-column
            prop="productNo"
            min-width="200"
            label="商品型号"
          ></el-table-column>
          <el-table-column
            prop="productName"
            min-width="300"
            label="商品名称"
          ></el-table-column>
          <el-table-column
            prop="productCode"
            min-width="260"
            label="序列号（SN）"
          ></el-table-column>
          <el-table-column
            prop="createDate"
            min-width="80"
            label="入库时间"
          ></el-table-column>
          <el-table-column
            prop="merOpenStatus"
            min-width="200"
            label="是否激活"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.merOpenStatus == 0">激活</span>
              <span v-if="scope.row.merOpenStatus == 1">未激活</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="merOpenDate"
            min-width="220"
            label="激活时间"
          ></el-table-column>
          <el-table-column
            prop="merName"
            min-width="200"
            label="商户姓名"
          ></el-table-column>
          <el-table-column
            prop="merPhone"
            min-width="200"
            label="商户电话"
          ></el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
<script>
import { Littlehow } from "../../assets/js/util";
import https from "../../plugins/https.js";
export default {
  data() {
    return {
      fficeUids: "",
      officeUid: "",
      options: [],
      officeListData: [],
      tableData: [
        {
          phone: "",
        },
      ],
    };
  },
  created() {
    var oemUid = localStorage.getItem("uid");
      https.assignmentOfficeList({}).then((res) => {
        console.log(res.data.data);
        let datas = res.data.data;
        datas.map((item) => {
          item.label = item.name;
          item.value = item.uid;
        });
        //
        var format = {
          id: "uid", //菜单编号，作为树形查找id
          root: "", //顶层节点的parentId是root
          pid: "parentUid", //父节点标识字段为parentId
          child: "children", //构造出的树形子节点数组名为children
          sort: { field: "sortNo", direct: 1 },
        }; //排序字段为sortNo，且正序;
        var result = Littlehow.tree.format(datas, format);
        this.options = result;
      })
      .catch((err) => {});
      https.assignmentList({uid: JSON.parse(this.$route.query.uid)}).then((res) => {
        console.log(res);
        this.tableData = res.data.data;
      }).catch(()=>{})
  },
  methods: {
    // 取消
    cancle() {
      this.$router.push("inventitoryDetails");
    },
    // 确定
    sure() {
      if (this.fficeUids == "") {
        return layer.open({
          content: "请选择转让对象",
          skin: "msg",
          time: 2,
        });
      }
        https.updateDeviceAffiliation({officeUid: this.fficeUids,
          sns: JSON.parse(this.$route.query.uid)})
        .then((res) => {
          if (res.data.code == "0000") {
            this.$router.push("inventitoryDetails");
          } else {
            return layer.open({
              content: res.data.msg,
              skin: "msg",
              time: 2,
            });
          }
        })
        .catch((err) => {});
    },
  },
};
</script>
<style scoped>
.con {
  position: relative;
}

.contbox6_10 {
  width: 100%;
  /*  height: 87.5vh; */
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.demo-form-inline {
  padding: 20px;
  padding-top:0;
  padding-bottom: 10px;
}
.el-button {
  padding: 8px 20px;
}
/deep/ .el-select > .el-input {
  width: 300px;
}
/deep/ .el-input__inner {
  width: 300px;
}
.button {
  margin-left: 20px;
  width: 200px;
  float: left;
}
/deep/ .el-input {
  width: 300px;
}
</style>
